#ifndef confbits_H_
#define confbits_H_
#include "msp430f5172.h"

void init(void);

inline void init()
{
	WDTCTL = WDTPW + WDTHOLD;				// Off goes the watchdog timer
	TD0CCTL0 = OUTMOD_4;                // CCR0 toggle
	TD0CCR0 = 9-1;                      // PWM Period/2
	TD0CCTL1 = OUTMOD_4;                // CCR1 toggle/set
	TD0CCR1 = 9;                        // CCR1 PWM duty cycle
	TD0CCTL2 = OUTMOD_4;                // CCR2 toggle/set
	TD1CCTL0 = OUTMOD_4;
	TD1CCR0 = 9-1;
	TD1CTL0 |= TDSSEL_2 + MC_1 + TDCLR;   // CCR2 PWM duty cycle
	TD0CTL0 |= TDSSEL_2 + MC_1 + TDCLR;   // SMCLK, up-mode, clear TDR, Start timer*/
	P2SEL &= ~BIT5 + ~BIT6 + ~BIT7;				// Off until detonation
	P1DIR = BIT5 + BIT6 + BIT7;								// Set P1.0 to output direction except RX
	P1DIR &= ~BIT0;														// IR weapon input
	P2DIR |= BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6 +BIT7;// Set P2.x to output directions
	P2SEL |= BIT5 + BIT6 + BIT7;							// Output PWM on pins 2.5, 2.6, 2.7 using TD0
	P3DIR &= ~BIT2 + ~BIT3 + ~BIT5 + ~BIT6;		// Input for timer damage/healing switch and IR reception
	P1IE |= BIT0;                            	// P1.1 interrupt enabled (getting shot by IR weapon)
	P1IES |= BIT0;                           	// P1.1 hi/lo edge
	P1IFG &= ~BIT0;                           // P1.1 IFG cleared
	//P1OUT |= BIT0;
	//P1REN |= BIT0;
	P1OUT = BIT7;															//P1.7 high for audio
	P2OUT = BIT0 + BIT1 + BIT2;								//P2.x high for audio
	P3OUT = 0x00;															//P3.x low
	//Timer A0  inti.
	 TA0CCTL0 = OUT;                          	// Set TXD Idle as Mark = '1'
	 TA0CCTL1 = SCS + CM1 + CAP + CCIE;       	// Sync, Neg Edge, Capture, Int
	 TA0CTL = TASSEL_2 + MC_2;                	// SMCLK, start in continuous mode
}

#endif
